package com.marvels.approve.process.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.Page;
import com.marvels.approve.loan.dto.ZxDataRespDTO;
import com.marvels.approve.process.dto.FaceSigAppointmentDTO;
import com.marvels.approve.process.dto.ProductCreditDataDTO;
import com.marvels.approve.process.service.CreditReportingService;
import com.marvels.common.dto.MarvelsResultDTO;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.exception.MarvelsErrorCode;
import com.marvels.common.utils.MarvelsLogUtil;
/**
 * 任务处理  -- 征信数据
 * @author liuyk
 *
 */
@RestController
@RequestMapping("/approve/process/credit_reporting/service")
public class CreditReportingController {
	@Autowired
	private CreditReportingService creditReportingService;
	@RequestMapping("/getDataList")
	@ResponseBody
	public MarvelsResultDTO getProductCreditData(String loanId){
		try {
			List<ProductCreditDataDTO> list = creditReportingService.getProductCreditData(loanId);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(), list);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>>>",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(),MarvelsErrorCode.FAIL.getDesc(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>>",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(),MarvelsErrorCode.ERROR.getDesc(), e.getMessage());
		}
	}
	/**
	 * 征信明细数据
	 * @param loanId
	 * @return
	 */
	@RequestMapping("getCreditDetail")
	@ResponseBody
	public MarvelsResultDTO getCreditDetail( ProductCreditDataDTO productCreditDataDTO){
		
		try {
			ZxDataRespDTO zxDataRespDTO = creditReportingService.getCreditDetail(productCreditDataDTO);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(),MarvelsErrorCode.SUCCESS.getDesc(), zxDataRespDTO);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>>>",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(),MarvelsErrorCode.FAIL.getDesc(), e.getMessage());
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>>",e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(),MarvelsErrorCode.ERROR.getDesc(), e.getMessage());
		}

	}
	
	
}
